//
//  LibraryViewController.m
//  Doc Ebook
//
//  Created by Vinh Huynh on 10/2/12.
//  Copyright (c) 2012 Hai Nguyen. All rights reserved.
//

#import "LibraryViewController.h"
#import "NewsCell.h"
#import "BookViewController.h"

@interface LibraryViewController ()<UITableViewDataSource, UITableViewDelegate>
{
    NSMutableArray *_listBooks;
}
@end

@implementation LibraryViewController

@synthesize libTable = _libTable;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_libTable release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setLibTable:nil];
    [super viewDidUnload];
}

#pragma mark - UItableView Delegate & Data Source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;//_listBooks.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return HEIGHT_NEWS_CELL;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"Cell ID";
    NewsCell *bookCell = (NewsCell *)[tableView dequeueReusableCellWithIdentifier:cellID];
    if (bookCell == nil) {
        bookCell = [[[NSBundle mainBundle]loadNibNamed:@"NewsCell" owner:self options:nil]lastObject];
    }
    return bookCell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Cell == > %i", indexPath.row);
    BookViewController *controller = [[BookViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

@end
